package com.ybkj.daijia.server.model;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import org.apache.commons.collections.CollectionUtils;

/**
 * 地区
 *
 * @author Shine
 */
public class Area extends Base {

    /**
     *
     */
    private static final long serialVersionUID = 1L;

    private String name;//地区名称

    private String memo;//收费说明

    private String adminCode;//行政区划代码

    private String adminCodeArr;//行政区划代码 本地数据数组
    /**
     * 公司ID
     */
    private Long companyId;
    private List<ChargeStartTime> chargeStartTimes;

    public Long getCompanyId() {
        return companyId;
    }

    public void setCompanyId(Long companyId) {
        this.companyId = companyId;
    }

    public String getAdminCode() {
        return adminCode;
    }

    public void setAdminCode(String adminCode) {
        this.adminCode = adminCode;
    }

    public String getAdminCodeArr() {
        return adminCodeArr;
    }

    public void setAdminCodeArr(String adminCodeArr) {
        this.adminCodeArr = adminCodeArr;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getMemo() {
        return memo;
    }

    public void setMemo(String memo) {
        this.memo = memo;
    }

    public List<ChargeStartTime> getChargeStartTimes() {
        return chargeStartTimes;
    }

    public void setChargeStartTimes(List<ChargeStartTime> chargeStartTimes) {
        this.chargeStartTimes = chargeStartTimes;
    }

    public void sortDistance() {
        if (CollectionUtils.isNotEmpty(chargeStartTimes)) {
            for (ChargeStartTime cst : chargeStartTimes) {
                if (CollectionUtils.isNotEmpty(cst.getChargeStartDistances())) {
                    if (cst.getChargeStartDistances().size() > 1) {
                        Collections.sort(cst.getChargeStartDistances(),
                            new Comparator<ChargeStartDistance>() {
                                public int compare(ChargeStartDistance arg0,
                                    ChargeStartDistance arg1) {
                                    return arg0.getId().compareTo(arg1.getId());
                                }
                            });
                    }
                }
            }
        }
    }

    public void sortWeight() {
        if (CollectionUtils.isNotEmpty(chargeStartTimes)) {
            for (ChargeStartTime cst : chargeStartTimes) {
                if (CollectionUtils.isNotEmpty(cst.getChargeStartNewWeights())) {
                    if (cst.getChargeStartNewWeights().size() > 1) {
                        Collections.sort(cst.getChargeStartNewWeights(),
                            new Comparator<ChargeStartNewWeight>() {
                                public int compare(ChargeStartNewWeight arg0,
                                    ChargeStartNewWeight arg1) {
                                    return arg0.getId().compareTo(arg1.getId());
                                }
                            });
                    }
                }
            }
        }
    }


    @Override
    public String toString() {
        return "Area{" +
            "name='" + name + '\'' +
            ", memo='" + memo + '\'' +
            ", adminCode='" + adminCode + '\'' +
            ", adminCodeArr='" + adminCodeArr + '\'' +
            ", chargeStartTimes=" + chargeStartTimes +
            '}';
    }
}

